﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.Net.Mail;
using System.Net.Configuration;
using OsPortal;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.Text;
using System.Xml;
using System.Web.Caching;


/// <summary>
/// Summary description for clsCommon
/// </summary>
/// 


public static class basConst
{
    //Const Mã các danh mục
    public const int CHUONG_TRINH_DAO_TAO = 1;
    //------------------------------------------

    public const string POSTSIGN = "99999999";
    public const string PR_USERCONTROL_NAME = "mo";

    //Thời gian sống của cache
    public const int timeCache = 30;
    //Thời gian sống của cookie 30 ngay
    public const int timeCookie = 30;

    //Cookie
    public const string COOKIE_USER_INFO = "userInfo_cookie";
    public const string COOKIE_USER_ID = "US_ID";
    public const string COOKIE_USER_NAME = "us_hoten";
    public const string COOKIE_USER_EMAIL = "us_email";
    public const string COOKIE_USER_LASTLOGIN = "us_lastlogin";

    //QueryString
    public const string QR_URL_REDERECT = "rturl";
    public const string QR_URL_ID = "id";

    //MOD-ACTION====================================================
    public const string MOD_ADD = "A";
    public const string MOD_UPDATE = "U";
    public const string MOD_DELETE = "D";
    public const string MOD_CHANGE = "C";

    // TRANG HIỆN TẠI
    public const int CURENT_PAGE = 1;
    //So luong san pham / 1 trang
    public const int PROC_NUMBER = 20;
    public const int NEWS_NUMBER = 2;
    //Message system
    public const string DATAISNULL="Không có dữ liệu";
    public const string SUSSCESS_ACT = "Thao tác thành công.!";
    //Duong dan luu tru
    public const string PATH_IMAGES_USER = "~/Images/news/";
    public const string PATH_IMAGES_DANHMUC = "~/Images/danhmuc/";

    // ĐƯỜNG DẪN LƯU TRỮ FILE TEXT
    public const string LinkFormMailNhanQuaTang = "SaveFile/FormMailQuaTang.txt";
    public const string LinkFormMailActiveAccount = "SaveFile/FormMailActiveAccount.txt";
    public const string LinkFormGetPassword = "SaveFile/FormGetPassWord.txt";
    public const string LinkFormMailGopY = "SaveFile/FormMailGopY.txt";
    public const string LinkPOPUP_AV_Index = "SaveFile/Popup_AV_Index.txt";
    public const string LinkLienKetLogo = "SaveFile/LienKetLogo.txt";
    public const string LinkIndexFormNhanQua = "SaveFile/index-form-nhan-qua-tang.txt";
    public const string LinkSlideQuangCao = "SaveFile/Slide_AV_Index.txt";
    public const string LinkPOPUPFACEBOOK = "SaveFile/PopUp-LikeFacebook.txt";
    public const string LinkQuangCao_LEFT = "SaveFile/Left_AV.txt";
    public const string LinkTextLink = "SaveFile/TextLink.txt";
    public const string LinkSlideTrangChu = "SaveFile/Slide-Trang-Chu.txt";
    public const string LinkGioithieu = "SaveFile/Gioithieu.txt";
    public const string LinkThanhtoan = "SaveFile/Thanhtoan.txt";
    public const string LinkTuyenDung = "SaveFile/TuyenDung.txt";
    public const string LinkLienHe = "SaveFile/lienhe.txt";
    public const string LinkWEBFORM_EMAIL = "SaveFile/webform-email.txt";
    //
    public const string PT_TOAN_QUOC = "toan-quoc";
    //
    public const string KP_TAT_CA = "cho-thue-phong-tro-nha-tro";
    public static string[] gstrNhaMangGameBank = { "", "Viettel", "Mobifone", "Vinaphone", "Gate", "VTC" };

    //SESSTION
    public const string SESSTION_MOBILE_STATUS = "mobile_status";
    //
    public const string MOBILE_STATUS_NULL = "NULL";
    public const string MOBILE_STATUS_TRUE = "TRUE";
    public const string MOBILE_STATUS_FALSE = "FALSE";
    
}
/*------------------------------------------------------------*/


public static class clsCommon
{
    static string strClassName = "clsCommon";

    /// <summary>
    /// Lấy IP của máy đang truy cập
    /// </summary>
    /// <returns></returns>
    public static string fncGetClientIP()
    {
        string ipList = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

        if (!string.IsNullOrEmpty(ipList))
        {
            return ipList.Split(',')[0];
        }

        return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    }

    /// <summary>
    /// Get Route
    /// </summary>
    /// <param name="objPage">this.Page</param>
    /// <param name="strParam">Param</param>
    /// <returns></returns>
    public static string fncGetRoute(System.Web.UI.Page objPage, string strParam)
    {
        return OsPortal.oStringHelper.fncCnvNullToString(objPage.RouteData.Values[strParam]);
    }

    /// <summary>
    /// Tự động load UserControl
    /// </summary>
    /// <param name="plhControl">PlaceHolderID</param>
    /// <param name="objPage">This.Page</param>
    /// <param name="strFolderUrl">Thư mục chứa userControl</param>
    /// <param name="strUCDefault">UserControl mặc định</param>
    public static void fncLoadUserControl(PlaceHolder plhControl, System.Web.UI.Page objPage, string strFolderUrl, string strUCDefault)
    {
        string Param = HttpContext.Current.Request.QueryString.Get(basConst.PR_USERCONTROL_NAME);
        fncLoadUserControl(plhControl, objPage, strFolderUrl, Param, strUCDefault);
    }

    /// <summary>
    /// Tự động load UserControl
    /// </summary>
    /// <param name="plhControl">PlaceHolderID</param>
    /// <param name="objPage">This.Page</param>
    /// <param name="strFolderUrl">Thư mục chứa userControl</param>
    /// <param name="strUCDefault">UserControl mặc định</param>
    public static void fncLoadUserControl(PlaceHolder plhControl, System.Web.UI.Page objPage, string strFolderUrl, string strControName, string strUCDefault)
    {
        string Param = strControName;
        try
        {
            if (!string.IsNullOrEmpty(Param))
            {
                string str = strFolderUrl + Param.ToString() + ".ascx";
                plhControl.Controls.Add(objPage.LoadControl(str));
            }
            else
            {
                Param = strUCDefault;
                string str = strFolderUrl + Param.ToString() + ".ascx";
                plhControl.Controls.Add(objPage.LoadControl(str));
            }
        }
        catch (Exception ex)
        {
            //OsPortal.oFileHelper.WriteLogErr(strClassName, "fncLoadUserControl()", ex.ToString());
            HttpContext.Current.Response.Redirect("/404");
        }
    }


    /// <summary>
    /// Tự động tạo mã để insert vào CSDL
    /// </summary>
    /// <param name="strTienTo">Tiền Tố Của Mã VD: TD</param>
    /// <param name="strTenBang">Tên bảng</param>
    /// <param name="strTenKhoaChinh">Tên khóa chính</param>
    /// <returns></returns>
    public static string fncAutoCreateID(string strTienTo, string strTenBang, string strTenKhoaChinh)
    {
        DataTable dt = oSqlDataHelper.sExecuteDataTable("select max(" + strTenKhoaChinh + ") 'id' from " + strTenBang + "", null);
        Console.Write(dt.Rows.Count);

        try
        {
            string strMaCuoiCung = dt.Rows[0]["id"].ToString();
            string kq = "";
            int so = int.Parse(strMaCuoiCung.Substring(2));
            if (so + 1 < 999999)
                kq = strTienTo + (so + 1);
            if (so + 1 < 100000)
                kq = strTienTo + "0" + (so + 1);
            if (so + 1 < 10000)
                kq = strTienTo + "00" + (so + 1);
            if (so + 1 < 1000)
                kq = strTienTo + "000" + (so + 1);
            if (so + 1 < 100)
                kq = strTienTo + "0000" + (so + 1);
            if (so + 1 < 10)
                kq = strTienTo + "00000" + (so + 1);

            return kq;
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncAutoCreateID", ex.ToString());
            return strTienTo + "000001";
        }
    }

    /// <summary>
    /// Lấy giá trị của Parameter
    /// </summary>
    /// <param name="strParameterName">Tên Parameter</param>
    /// <returns>Giá trị trả về là "" nếu ko lấy được</returns>
    public static string getParameter(string strParameterName)
    {
        string strValue = "";
        try
        {
            strValue = HttpContext.Current.Request.QueryString[strParameterName];
            if (strValue == null)
                return strValue = "";
        }
        catch (Exception)
        {
            strValue = "";
        }

        return strValue;
    }

    /// <summary>
    /// Trả về phần đầu của chuỗi và đảm bảo đủ từ
    /// </summary>
    /// <param name="s"></param>
    /// <param name="length">Số ký tự tối đa được cắt</param>
    /// <returns>Chuoi can cat</returns>
    public static string fncCatChuoi(string s, int length)
    {
        if (String.IsNullOrEmpty(s))
            return "";
        var words = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (words[0].Length > length)
            return s;
        var sb = new StringBuilder();
        foreach (var word in words)
        {
            if ((sb + word).Length > length)
                return string.Format("{0}...", sb.ToString().TrimEnd(' '));
            sb.Append(word + " ");
        }
        return string.Format("{0}...", sb.ToString().TrimEnd(' '));
    }

    /// <summary>
    /// Lấy một chuỗi ngẫu nhiên
    /// </summary>
    /// <param name="codeCount">Số lượng ký tự</param>
    /// <returns></returns>
    public static string NgauNhien_SoChu(int codeCount)
    {
        string allChar = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
        string[] allCharArray = allChar.Split(',');
        string randomCode = "";
        int temp = -1;

        Random rand = new Random();
        for (int i = 0; i < codeCount; i++)
        {
            if (temp != -1)
            {
                rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
            }
            int t = rand.Next(36);
            if (temp != -1 && temp == t)
            {
                return NgauNhien_SoChu(codeCount);
            }
            temp = t;
            randomCode += allCharArray[t];
        }
        return randomCode;
    }

}

/*---------------------public calss expost HTLML------------------*/
public class clsExportHtml
{
    static string strClassName = "clsExportHtml";

    /// <summary>
    /// Hiển thị danh sách chương trình đào tạo
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportCTDT(DataTable dtSource)
    {
        if (dtSource == null) return "";
        StringBuilder sbHtml = new StringBuilder("");
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strDM_ID = dtSource.Rows[i]["DM_ID"].ToString().ToLower();
                string strdm_tieude = dtSource.Rows[i]["dm_tieude"].ToString();
                string strdm_tieude_kodau = dtSource.Rows[i]["dm_tieude_kodau"].ToString().ToLower();
                string strdm_anh = dtSource.Rows[i]["dm_anh"].ToString();
                //
                string strURL = "/" + strdm_tieude_kodau;
                sbHtml.Append("<li><div class='img-ctdt'><a title='" + strdm_tieude_kodau + "' href='" + strURL + "'>");
                sbHtml.Append("<img alt='" + strdm_tieude_kodau + "' src='" + strdm_anh + "'>");
                sbHtml.Append("</div></a>");
                sbHtml.Append("<div class='title-news'><a href='" + strURL + "'>" + strdm_tieude + "</a></div>");
                sbHtml.Append("</li>");
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportCTDT", ex.ToString());
        }
        return sbHtml.ToString();
    }
    /// <summary>
    /// Hiển thị menu
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportMenuNav(DataTable dtSource)
    {
        if (dtSource == null) return "";
        StringBuilder sbHtml = new StringBuilder("");
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strDM_ID = dtSource.Rows[i]["DM_ID"].ToString().ToLower();
                string strdm_tieude = dtSource.Rows[i]["dm_tieude"].ToString();
                string strdm_tieude_kodau = dtSource.Rows[i]["dm_tieude_kodau"].ToString().ToLower();
                string strdm_anh = dtSource.Rows[i]["dm_anh"].ToString();
                string strdm_logo = dtSource.Rows[i]["dm_logo"].ToString();
                //
                if (strdm_tieude_kodau == "chuong-tring-dao-tao")
                {
                    continue;
                }
                string strURL = "/" + strdm_tieude_kodau;
                sbHtml.Append("<a class='nav-item' title='" + strdm_tieude_kodau + "' href='" + strURL + "'>");
                sbHtml.Append("<img title='" + strdm_tieude_kodau + "' alt='alt' src='" + strdm_logo + "'/><h2>" + strdm_tieude + "</h2>");
                sbHtml.Append("</a>");
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportCTDT", ex.ToString());
        }
        return sbHtml.ToString();
    }

    /// <summary>
    /// Hiển thị menu footer
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportMenuFooter(DataTable dtSource)
    {
        if (dtSource == null) return "";
        StringBuilder sbHtml = new StringBuilder("");
        try
        {
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strDM_ID = dtSource.Rows[i]["DM_ID"].ToString().ToLower();
                string strdm_tieude = dtSource.Rows[i]["dm_tieude"].ToString();
                string strdm_tieude_kodau = dtSource.Rows[i]["dm_tieude_kodau"].ToString().ToLower();
                string strdm_anh = dtSource.Rows[i]["dm_anh"].ToString();
                string strdm_logo = dtSource.Rows[i]["dm_logo"].ToString();
                //
                if (strdm_tieude_kodau == "chuong-tring-dao-tao")
                {
                    continue;
                }
                string strURL = "/" + strdm_tieude_kodau;
                sbHtml.Append("<a class='nav-itemF' title='" + strdm_tieude_kodau + "' href='" + strURL + "'>");
                sbHtml.Append("<h2>" + strdm_tieude + "</h2>");
                sbHtml.Append("</a>");
            }
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportCTDT", ex.ToString());
        }
        return sbHtml.ToString();
    }

    /// <summary>
    /// Hiển thị lịch khai giảng
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportLichKhaiGiang(DataTable dtSource)
    {
        if (dtSource == null) return "";
        StringBuilder sbHtml = new StringBuilder("");
        StringBuilder sbHtmlHeadHocThu = new StringBuilder("");
        StringBuilder sbHtmlHeadHocThat = new StringBuilder("");
        StringBuilder sbHtmlHeadHuanLuyen = new StringBuilder("");
        StringBuilder sbHtmlHeadQuaTang = new StringBuilder("");
        StringBuilder sbHtmlHeadDichVu = new StringBuilder("");
        int countHocThat = 0;
        int countHocThu = 0;
        int countHuanLuyen = 0;
        int countQuaTang = 0;
        int countDichVu = 0;
        try
        {
            //Head có lịch
            StringBuilder sbHtmlHeadCoLich = new StringBuilder("");
            sbHtmlHeadCoLich.Append("<table class='table tblLichKhaiGiang'><tr><th style='width: 75px;'></th>");
            sbHtmlHeadCoLich.Append("<th>Tên khóa học</th><th style='width: 125px;'>Đầu tư</th>");
            sbHtmlHeadCoLich.Append("<th style='width: 100px;'>Thời gian</th><th style='width: 55px;'>Bắt đầu</th>");
            sbHtmlHeadCoLich.Append("<th style='width: 55px;'>Kết thúc</th></tr>");
            //Head không có lịch
            StringBuilder sbHtmlHeadKoLich = new StringBuilder("");
            sbHtmlHeadKoLich.Append("<table class='table tblLichKhaiGiang'><tr><th style='width: 75px;'></th>");
            sbHtmlHeadKoLich.Append("<th>Tên khóa học</th><th style='width: 125px;'>Đầu tư</th>");
            sbHtmlHeadKoLich.Append("<th style='width: 100px;'>Thời gian</th></tr>");
            //---------------------------------------------------------------------------------------------------
            //Học Thật
            sbHtmlHeadHocThat.Append("<section class='news-top'><header><span>Lịch khai giảng khóa học chính thức</span></header>");
            sbHtmlHeadHocThat.Append(sbHtmlHeadCoLich.ToString());
            //Học thử
            sbHtmlHeadHocThu.Append("<section class='news-top'><header><span>Lịch khai giảng khóa học thử</span></header>");
            sbHtmlHeadHocThu.Append(sbHtmlHeadCoLich.ToString());
            //Huấn luyện 1vs1
            sbHtmlHeadHuanLuyen.Append("<section class='news-top'><header><span>Huấn luyện 1 kèm 1</span></header>");
            sbHtmlHeadHuanLuyen.Append(sbHtmlHeadKoLich.ToString());
            //Quà Tặng
            sbHtmlHeadQuaTang.Append("<section class='news-top'><header><span>Quà tặng</span></header>");
            sbHtmlHeadQuaTang.Append(sbHtmlHeadCoLich.ToString());
            //Dịch Vụ
            sbHtmlHeadDichVu.Append("<section class='news-top'><header><span>DỊCH VỤ & HỖ TRỢ sau khóa học</span></header>");
            sbHtmlHeadDichVu.Append(sbHtmlHeadKoLich.ToString());
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString();
                string strTI_TIEUDE = dtSource.Rows[i]["TI_TIEUDE"].ToString();
                string strTI_TIEUDE_KODAU = dtSource.Rows[i]["TI_TIEUDE_KODAU"].ToString();
                string strTI_MOTA = dtSource.Rows[i]["TI_MOTA"].ToString().Trim();
                string strTI_ANH = dtSource.Rows[i]["TI_ANH"].ToString();
                string strTI_DAUTU = dtSource.Rows[i]["TI_DAUTU"].ToString().Trim();
                string strTI_THOIGIAN = dtSource.Rows[i]["TI_THOIGIAN"].ToString().Trim();
                DateTime dtStartDate = Convert.ToDateTime(dtSource.Rows[i]["TI_NGAY_BATDAU"]);
                DateTime dtEndtDate = Convert.ToDateTime(dtSource.Rows[i]["TI_NGAY_KETTHUC"]);
                string strDM1_TIEUDE_KODAU = dtSource.Rows[i]["DM1_TIEUDE_KODAU"].ToString();
                int iKieutin = OsPortal.oStringHelper.fncCnvNullToInt(dtSource.Rows[i]["TI_KIEUTIN"]);
                //
                string strURL = "/" + strDM1_TIEUDE_KODAU + "/" + strTI_TIEUDE_KODAU + "-" + strTI_ID;
                //
                StringBuilder sbHtmlCoLich = new StringBuilder("");
                sbHtmlCoLich.Append("<tr><td><div class='khung-avt-lkg'>");
                sbHtmlCoLich.Append("<img class='img-avt-lkg' alt='" + strTI_TIEUDE + "' src='/" + strTI_ANH + "' />");
                sbHtmlCoLich.Append("</div></td><td>");
                sbHtmlCoLich.Append("<h3><a title='" + strTI_TIEUDE + "' href='" + strURL + "'>" + strTI_TIEUDE + "</a></h3>");
                sbHtmlCoLich.Append("<div>" + strTI_MOTA + "</div></td><td>" + strTI_DAUTU + "</td><td>" + strTI_THOIGIAN + "</td>");
                sbHtmlCoLich.Append("<td>");
                sbHtmlCoLich.Append("<div class='calendar-lkg left cld-start'>");
                sbHtmlCoLich.Append("<div class='day-lkg'><span>" + OsPortal.oStringHelper.fncConvetDate2Thu(dtStartDate) + "</span></div>");
                sbHtmlCoLich.Append("<div class='date-lkg'><span>" + dtStartDate.Day + "</span></div>");
                sbHtmlCoLich.Append("<div class='montyear-lkg'>" + dtStartDate.Month + "/" + dtStartDate.Year + "</div>");
                sbHtmlCoLich.Append("</div></td><td>");
                sbHtmlCoLich.Append("<div class='calendar-lkg left cld-end'>");
                sbHtmlCoLich.Append("<div class='day-lkg'><span>" + OsPortal.oStringHelper.fncConvetDate2Thu(dtEndtDate) + "</span></div>");
                sbHtmlCoLich.Append("<div class='date-lkg'><span>" + dtEndtDate.Day + "</span></div>");
                sbHtmlCoLich.Append("<div class='montyear-lkg'>" + dtEndtDate.Month + "/" + dtEndtDate.Year + "</div>");
                sbHtmlCoLich.Append("</div></td></tr>");
                //
                StringBuilder sbHtmlKoLich = new StringBuilder("");
                sbHtmlKoLich.Append("<tr><td><div class='khung-avt-lkg'>");
                sbHtmlKoLich.Append("<img class='img-avt-lkg' alt='" + strTI_TIEUDE + "' src='/" + strTI_ANH + "' />");
                sbHtmlKoLich.Append("</div></td><td>");
                sbHtmlKoLich.Append("<h3><a title='" + strTI_TIEUDE + "' href='" + strURL + "'>" + strTI_TIEUDE + "</a></h3>");
                sbHtmlKoLich.Append("<div>" + strTI_MOTA + "</div></td><td>" + strTI_DAUTU + "</td><td>" + strTI_THOIGIAN + "</td>");
                sbHtmlKoLich.Append("</tr>");

                switch (iKieutin)
                {
                    case 1:
                        sbHtmlHeadHocThat.Append(sbHtmlCoLich.ToString());
                        countHocThat++;
                        break;
                    case 2:
                        sbHtmlHeadHuanLuyen.Append(sbHtmlKoLich.ToString());
                        countHuanLuyen++;
                        break;
                    case 3:
                        sbHtmlHeadHocThu.Append(sbHtmlCoLich.ToString());
                        countHocThu++;
                        break;
                    case 4:
                        sbHtmlHeadQuaTang.Append(sbHtmlCoLich.ToString());
                        countQuaTang++;
                        break;
                    case 5:
                        sbHtmlHeadDichVu.Append(sbHtmlKoLich.ToString());
                        countDichVu++;
                        break;
                    
                }
            }
            sbHtmlHeadHocThat.Append("</table></section>");
            sbHtmlHeadHuanLuyen.Append("</table></section>");
            sbHtmlHeadHocThu.Append("</table></section>");
            sbHtmlHeadQuaTang.Append("</table></section>");
            sbHtmlHeadDichVu.Append("</table></section>");
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportLichKhaiGiang", ex.ToString());
        }
        if (countHocThat > 0) sbHtml.Append(sbHtmlHeadHocThat.ToString());
        if (countHuanLuyen > 0) sbHtml.Append(sbHtmlHeadHuanLuyen.ToString());
        if (countHocThu > 0) sbHtml.Append(sbHtmlHeadHocThu.ToString());
        if (countQuaTang > 0) sbHtml.Append(sbHtmlHeadQuaTang.ToString());
        if (countDichVu > 0) sbHtml.Append(sbHtmlHeadDichVu.ToString());
        return sbHtml.ToString();
    }
    /// <summary>
    /// Hiển thị mini danh sách lịch khai giảng
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportLichKhaiGiang_Mini()
    {
        StringBuilder sbHtml = new StringBuilder("");
        DataTable dt_lkg = clsTinDang.fncTinDang_FND(1, 100, "lich-khai-giang",0, "lich-khai-giang", "", 1);
        if (dt_lkg == null) return "";
        sbHtml.Append("<div class='box-left'>");
        sbHtml.Append("<h4 class='title-left'>LỊCH KHAI GIẢNG MỚI NHẤT</h4>");
        sbHtml.Append("<ul class='ul-top-pt'>");
        for (int i = 0; i < dt_lkg.Rows.Count; i++)
        {
            string strTI_ID = dt_lkg.Rows[i]["TI_ID"].ToString();
            string strTI_TIEUDE = dt_lkg.Rows[i]["TI_TIEUDE"].ToString();
            string strTI_TIEUDE_KODAU = dt_lkg.Rows[i]["TI_TIEUDE_KODAU"].ToString();
            string strTI_ANH = dt_lkg.Rows[i]["TI_ANH"].ToString();
            string strDM1_TIEUDE_KODAU = dt_lkg.Rows[i]["DM1_TIEUDE_KODAU"].ToString();
            string strURL = "/" + strDM1_TIEUDE_KODAU + "/" + strTI_TIEUDE_KODAU + "-" + strTI_ID;
            sbHtml.Append("<li>");
            sbHtml.Append("<div style='background-color: #000' class='divImg'>");
            sbHtml.Append("<img alt='" + strTI_TIEUDE_KODAU + "' src='/" + strTI_ANH + "'></div>");
            sbHtml.Append("<h3><a class='title' href='" + strURL + "'>" + strTI_TIEUDE + "</a></h3>");
            sbHtml.Append("</li>");
        }
        sbHtml.Append("</ul>");
        sbHtml.Append("<div class='clr'></div>");
        sbHtml.Append("</div>");

        return sbHtml.ToString();
    }


    /// <summary>
    /// Hiển thị danh sách tin
    /// </summary>
    /// <param name="dtSource"></param>
    /// <returns></returns>
    public static string fncExportListTin(DataTable dtSource)
    {
        if (dtSource == null) return "";
        StringBuilder sbHtml = new StringBuilder("");
        try
        {
            sbHtml.Append("<div class='lstPhongTroVIP'>");
            for (int i = 0; i < dtSource.Rows.Count; i++)
            {
                string strTI_ID = dtSource.Rows[i]["TI_ID"].ToString();
                string strTI_TIEUDE = dtSource.Rows[i]["TI_TIEUDE"].ToString();
                string strTI_TIEUDE_KODAU = dtSource.Rows[i]["TI_TIEUDE_KODAU"].ToString();
                string strTI_MOTA = OsPortal.oStringHelper.ClearTagHTML(dtSource.Rows[i]["TI_MOTA"].ToString());
                string strTI_ANH = dtSource.Rows[i]["TI_ANH"].ToString();
                string strTI_DAUTU = dtSource.Rows[i]["TI_DAUTU"].ToString();
                string strTI_THOIGIAN = dtSource.Rows[i]["TI_THOIGIAN"].ToString();
                DateTime dtStartDate = Convert.ToDateTime(dtSource.Rows[i]["TI_NGAY_BATDAU"]);
                DateTime dtEndtDate = Convert.ToDateTime(dtSource.Rows[i]["TI_NGAY_KETTHUC"]);
                string strDM1_TIEUDE_KODAU = dtSource.Rows[i]["DM1_TIEUDE_KODAU"].ToString();
                //
                string strURL = "/" + strDM1_TIEUDE_KODAU + "/" + strTI_TIEUDE_KODAU + "-" + strTI_ID;
                sbHtml.Append("<div class='itemPTVip'>");
                sbHtml.Append("<div class='img-pt-vip'>");
                sbHtml.Append("<img alt='alt' src='/" + strTI_ANH + "'>");
                sbHtml.Append("</div>");
                sbHtml.Append("<div class='description-pt-vip'>");
                sbHtml.Append("<h3><a href='" + strURL + "'>" + strTI_TIEUDE + "</a></h3>");
                sbHtml.Append("<p>" + strTI_MOTA + "</p>");
                sbHtml.Append("</div>");
                sbHtml.Append("<div class='clr'></div>");
                sbHtml.Append("</div>");
            }
            sbHtml.Append("</div>");
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "fncExportListTin", ex.ToString());
        }
        return sbHtml.ToString();
    }

    /// <summary>
    /// Like Button
    /// </summary>
    /// <returns></returns>
    public static string fncLikeButton()
    {
        string strUrl = HttpContext.Current.Request.Url.AbsoluteUri;
        string strHtml = "<div class='g-plusone' data-href='" + strUrl + "'></div>";
        strHtml += "<div class='fb-like' data-href='https://www.facebook.com/nghikhacgroup' data-colorscheme='light' data-layout='standard' data-action='like' data-show-faces='false' data-send='false' width='400'></div>";
        return strHtml;
    }

    /// <summary>
    /// Comment Facebook
    /// </summary>
    /// <returns></returns>
    public static string fncExportConmentFacebook()
    {
        return "<div class='fb-comments' data-href='" + HttpContext.Current.Request.Url.AbsoluteUri + "' data-width='714' data-num-posts='10'></div>";
    }
}